home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue30 / mmapfile / MMAPFILE.ZIP / UMEM1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-06-22  |  1.5 KB  |  69 lines

  1. unit UMem1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Buttons,E_MemMap;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     SpeedButton1: TSpeedButton;
  12.     SpeedButton2: TSpeedButton;
  13.     procedure SpeedButton1Click(Sender: TObject);
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure FormDestroy(Sender: TObject);
  16.     procedure SpeedButton2Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.     EMemMap : TEMemMap;
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28. {$R *.DFM}
  29. Type
  30.      IntPtr = ^Integer;
  31.  
  32. procedure TForm1.FormCreate(Sender: TObject);
  33. Var
  34.    AnInt   : Integer;
  35. begin
  36.   EMemMap:=TEMemMap.Create(Self);
  37.   If NOT EMemMap.MapExisting('DAVESMAP',SizeOf(Integer)) then
  38.   begin
  39.     AnInt:=3;
  40.     If NOT EMemMap.CreateMemMap('DAVESMAP',SizeOf(Integer),AnInt) then
  41.       Messagedlg('Error Creating map',mtInformation,[mbOk],0);
  42.   end;
  43. end;
  44. procedure TForm1.FormDestroy(Sender: TObject);
  45. begin
  46.   EMemMap.Free;
  47. end;
  48. procedure TForm1.SpeedButton1Click(Sender: TObject);
  49. Var
  50.    AnInt   : Integer;
  51. begin
  52.   AnInt:=IntPtr(EMemMap.MemMap)^;
  53.   MessageDlg(IntToStr(AnInt),mtInformation,[mbOk],0);
  54. end;
  55.  
  56. procedure TForm1.SpeedButton2Click(Sender: TObject);
  57. Var
  58.     AValue : String;
  59.     AnInt  : Integer;
  60. begin
  61.   AnInt:=IntPtr(EMemMap.MemMap)^;
  62.   AValue:=IntToStr(AnInt);
  63.   InputQuery('Get Value','NewValue',AValue);
  64.   AnInt:=StrToInt(AValue);
  65.   IntPtr(EMemMap.MemMap)^:=AnInt;
  66. end;
  67.  
  68. end.
  69.